#include <iostream>
using namespace std;

int c[6], m[6] = {1, 5, 10, 50, 100, 500}, nums[6], money;
void solve();

int main() {
    cin >> c[0] >> c[1] >> c[2] >> c[3] >> c[4] >> c[5] >> money;
    solve();
    return 0;
}

void solve() {
    for (int i = 5; i >= 0; i--) {
        nums[i] = min(money / m[i], c[i]);
        money -= m[i] * nums[i];
    }
    for (int i = 0; i < 6; i++) {
        cout << nums[i] << ' ';
    }
}